package Demo5;
import java.util.Arrays;

public class MyBubbleSortDemo {
    public static void main(String[] args) {
        int [] arr ={8,3,19,23,4};
        bubbleSort(arr);
        printArr(arr);
    }

    private static void bubbleSort(int[] arr) {
        for (int j = 0; j < arr.length-1; j++) {
            for (int i = 0; i < arr.length-1-j ; i++) {
                if(arr[i]> arr[i+1]){
                    int temp = arr[i];
                    arr[i]= arr[i+1];
                    arr[i+1]=temp;
                }
            }
        }
    }

    private static void printArr(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

}
